﻿using STT.Business;
using STT.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace STT.Admin.UserControls
{
    public partial class ucTimKiemKhoaHoc : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {           
        }

        protected void lbXuatDuLieu_Click(object sender, EventArgs e)
        {
          
        }

        void LoadData()
        {
            gvKhoaHoc.DataSource = BTbKhoaHoc.SelectCoursesBySearch(new ETbKhoaHoc
            {
                MaKhoaHoc = txtMaKhoaHoc.Text.Trim() != "" ? int.Parse(txtMaKhoaHoc.Text.Trim()) : -1,
                TenKhoaHoc = txtTenKhoaHoc.Text.Trim(),
                DiaDiemHoc = txtPhongHoc.Text.Trim(),
                ThoiGianBatDau = txtThoiGianBatDau.Text.Trim() == "" ? default(DateTime) : DateTime.Parse(txtThoiGianBatDau.Text),
                ThoiGianKetThuc = txtThoiGianKetThuc.Text.Trim() == "" ? default(DateTime) : DateTime.Parse(txtThoiGianKetThuc.Text),
            }, txtTenGiangVien.Text.Trim(),
           txtSoHocVien.Text.Trim() != "" ? int.Parse(txtSoHocVien.Text.Trim()) : -1,
           txtLopHoc.Text.Trim(),
           txtNamHoc.Text
           );

            gvKhoaHoc.DataBind();
        }

        protected void btTimKiem_Click(object sender, EventArgs e)
        {
            LoadData();
         
            //ScriptManager.RegisterClientScriptBlock(this, GetType(), "Thông báo!", "<script>alert('" + txtThoiGianKetThuc.Text + "')</script>", false);
        }

        protected void gvKhoaHoc_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            gvKhoaHoc.PageIndex = e.NewPageIndex;

            LoadData();            
        }
    }
}